package com.hspedu.abstract_;

/**
 * 抽象类练习题：
 * 1. abstract final class A{} 能编译通过吗？ 错误 final不能继承
 * 2. abstract public static void test2(){} 能编译通过吗？ 错误 static关键字和方法重写无关，抽象方法没有方法体，不能被类直接调用
 * 3. abstract private void test3(); 能编译通过吗? 错误 私有的方法不能重写，abstract要求必须重写
 * 4. 编写一个Employee类，声明为抽象类，包含如下三个属性：name, id, salary. 提供必要的构造器和抽象方法，work().
 *    对于Manager类来说，他既是员工还具有奖金bonus的属性，请使用继承的思想，设计CommonEmployee类和Manager类，
 *    要求类中提供必要的方法进行属性访问，实现work(), 提示“经理/普通员工 名字 工作中”
 */
public class AbstractExercise01 {
    public static void main(String[] args) {
        CommonEmployee commonEmployee = new CommonEmployee("张三", 2022, 9000);
        Manager manager = new Manager("李四", 2023, 10000, 5000);
        commonEmployee.work();
        manager.work();
    }
}


abstract class Employee {
    private String name;
    private int id;
    private double salary;

    public Employee() {
    }

    public Employee(String name, int id, double salary) {
        this.name = name;
        this.id = id;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public abstract void work();
}

class Manager extends Employee{

    private double bonus;

    public Manager() {
    }

    public Manager(String name, int id, double salary, double bonus) {
        super(name, id, salary);
        this.bonus = bonus;
    }

    @Override
    public void work() {
        System.out.println("经理" + getName() + "工作中");
    }
}

class CommonEmployee extends Employee{
    public CommonEmployee() {
    }

    public CommonEmployee(String name, int id, double salary) {
        super(name, id, salary);
    }

    @Override
    public void work() {
        System.out.println("普通员工" + getName() + "工作中");
    }
}